package car.aistar.service.impl;

import car.aistar.dao.CarBrandsDao;
import car.aistar.entity.CarBrands;
import car.aistar.service.CarBrandsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (CarBrands)表服务实现类
 *
 * @author makejava
 * @since 2020-09-30 20:14:23
 */
@Service("carBrandsService")
public class CarBrandsServiceImpl implements CarBrandsService {
    @Autowired
    private CarBrandsDao carBrandsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CarBrands queryById(Long id) {
        return this.carBrandsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CarBrands> queryAllByLimit(int offset, int limit) {
        return this.carBrandsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param carBrands 实例对象
     * @return 实例对象
     */
    @Override
    public CarBrands insert(CarBrands carBrands) {
        this.carBrandsDao.insert(carBrands);
        return carBrands;
    }

    /**
     * 修改数据
     *
     * @param carBrands 实例对象
     * @return 实例对象
     */
    @Override
    public CarBrands update(CarBrands carBrands) {
        this.carBrandsDao.update(carBrands);
        return this.queryById(carBrands.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.carBrandsDao.deleteById(id) > 0;
    }

    /**
     * 查询所有
     * @return
     */
    @Override
    public List<CarBrands> findAll() {
        List<CarBrands> carBrandsList = carBrandsDao.findAll();
        return carBrandsList;
    }

    @Override
    public List<CarBrands> queryAll(CarBrands carBrands) {
        List<CarBrands> carBrandsList = carBrandsDao.queryAll(carBrands);
        return carBrandsList;
    }


}